package com.peng.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peng.pojo.Clazz;
import com.peng.service.ClazzService;
import com.peng.mapper.ClazzMapper;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
* @author dell
* @description 针对表【tb_clazz】的数据库操作Service实现
* @createDate 2022-05-15 13:39:04
*/
@Service
public class ClazzServiceImpl extends ServiceImpl<ClazzMapper, Clazz> implements ClazzService{

    @Override
    public IPage<Clazz> getClazzsByOpr(Integer pageNo, Integer pageSize, String gradeName,String name) {
        Page<Clazz> clazzPage = new Page<>(pageNo, pageSize);
        LambdaQueryWrapper<Clazz> queryWrapper = new LambdaQueryWrapper<>();
        if (!StringUtils.isEmpty(gradeName)){
            queryWrapper.like(Clazz::getGradeName,gradeName);
        }
        if (!StringUtils.isEmpty(name)){
            queryWrapper.like(Clazz::getName,name);
        }
        Page<Clazz> clazzPage1 = baseMapper.selectPage(clazzPage, queryWrapper);
        return clazzPage1;
    }
}




